﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RealTimeCharts.LineChart
{
    public class PolyLine : ShapeBase
    {
        public List<PixelPoint> pixelPoints = null;

        public PolyLine() { }

        public PolyLine(Graphics g, List<PixelPoint> points, Color lineColor,int lineWidth):base(g,new Pen(lineColor, lineWidth))
        {
            pixelPoints = points;
        }

        public PolyLine(Graphics g,List<PixelPoint> points, Pen p):base(g,p)
        {
            pixelPoints=points;
        }

        public override void Show()
        {
            Show(gs, pen);
        }

        public void Show(Graphics g,Pen p)
        {
            PixelPoint p1 = new PixelPoint(pixelPoints[0].X, pixelPoints[0].Y);
            PixelPoint p2 = null;
            //PointF[] pointfs = new PointF[pixelPoints.Count];
            for(int i = 1;i<pixelPoints.Count;i++)
            {
                p2 = new PixelPoint(pixelPoints[i].X, pixelPoints[i].Y);
                g.DrawLine(p, (float)p1.X, (float)p1.Y, (float)p2.X, (float)p2.Y);
                p1 = p2;
                //pointfs[i] = new PointF(pixelPoints[i].X, pixelPoints[i].Y);
            }
            //g.DrawCurve(p, pointfs, 0.5f);
        }
    }
}
